package org.jtb.quickr;

import java.util.Properties;

/**
 * Quickr upload service.
 */
public class UploadService extends Service {
    /**
     * Construct a new upload service and load quickr.properties from the class path.
     * @throws QuickrException If there was a problem constructing this object.
     */
    public UploadService() throws QuickrException {
        super();
    }
    
    /**
     * Construct a new upload photos service based on the given properties.
     * @param properties The quickr properties.
     * @throws QuickrException If a problem occurs constructing this object.
     */
    public UploadService(Properties properties) throws QuickrException {
        super(properties);
    }    
    
    /**
     * Call the Flickr photo upload service.
     * For details, see the
     * <a href="http://www.flickr.com/services/api/upload.api.html">
     * Flickr Synchronous Upload API</a> documentation.
     * @param uploadCriteria The photo upload criteria.
     * @param authToken The authentication token. This method requires a valid
     * authentication token.
     * @return The ID of the uploaded photo.
     * @throws QuickrException If there was a problem uploading the photo.
     */
    public PhotoIdResponse upload(AuthResponse.Token authToken, UploadCriteria uploadCriteria) throws QuickrException {
        UploadRequest ur = new UploadRequest(properties.getUploadUrl(), properties.getApiKey(), properties.getSecret(), authToken, uploadCriteria);
        PhotoIdResponse pid = ur.execute();
        
        return pid;
    }
}
